#pragma once

#include "Common.h"

enum class PieceColor : signed char
{
	None = 0,
	White = 1,
	Black = -1
};

inline PieceColor other_color(PieceColor color)
{
	return (PieceColor) -(signed char) color;
}

inline PieceColor operator !(PieceColor color)
{
	return other_color(color);
}

enum class PieceType : char
{
	King = 0,
	Queen = 1,
	Rook = 2,
	Bishop = 3,
	Knight = 4,
	Pawn = 5,
	None = 6
};

struct Piece 
{
	PieceColor Color;
	PieceType Type;

	Piece() : Type(PieceType::None) { }
	Piece(PieceType type, PieceColor color)
		: Color(color), Type(type) { }

	explicit operator bool() const
	{
		return Type != PieceType::None;
	}

	Piece &operator=(bool val)
	{
		//if (!val)
		{
			Type = PieceType::None;
#if _DEBUG
			Color = PieceColor::None;
#endif
		}
		return *this;
	}

	bool operator==(PieceColor color) const
	{
		return Color == color;
	}
	bool operator==(PieceType type) const
	{
		return Type == type;
	}
	bool operator!=(PieceColor color) const
	{
		return Color != color;
	}
	bool operator!=(PieceType type) const
	{
		return Type != type;
	}
};